package com.wobangkj.common.api.crud;

import com.alibaba.fastjson.JSONObject;
import com.wobangkj.common.model.crud.Resume;
import com.wobangkj.common.service.ResumeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/resume")
public class ResumeController {
    @Autowired
    private ResumeService resumeService;

    @PostMapping(value = "/create")
    public Object create(@RequestBody Resume data) {
        Resume resume=resumeService.findByUserId(data.getResumeId());
        if(resume!=null)
        {
            return resumeService.update(data);
        }
        else {
            return resumeService.create(data);
        }
    }

    @GetMapping("/findByUserId")
    public Object findByUserId(String id){
        Map<String, Object> modelMap = new HashMap();
        modelMap.put("status",201);
        modelMap.put("msg","请求成功");
        modelMap.put("resumeList",resumeService.findById(id));
        return modelMap;
    }
}
